import requests
nr2 = []
code200 = []
code404 = []
codeOther = []

with open(r'C:\Users\01383317\UrlList', 'r') as f:
  nr = f.readlines()
  for line in nr:
      line = line.rstrip("\n")
      nr2.append(line)

#print(nr2)

		
for i in range(len(nr2)):
  try:
    code = requests.get(nr[i]).status_code
    if code == 200:
      code200.append(str(code))
    elif code == 404:
      code404.append(str(code))
    else:
      codeOther.append(str(code))
    print(nr[i], code)
    #print(code200, code404, codeOther)
  except requests.exceptions.ConnectionError as e:
    print(nr[i], e)
	
#print(nr[i], code)
print('\n','状态码为200:', code200, '\n','状态码为404:', 
        code404,'\n','状态码为其他:', codeOther)
  
#for i in range(len(nr2)):
#    try:
#        code = requests.get(nr[i]).status_code
#        print(nr[i], code)
#    except requests.exceptions.ConnectionError as e:
#        print(nr[i], e)

#code = requests.get("https://api.sudaizhijia.cm/").status_code
#print(code)
#except requests.exceptions.ConnectionError as e:
#    print(e)

